home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94b.txt
/
000114_icon-group-sender _Sun Nov 20 21:40:31 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1995-02-09
|
4KB
Received: by cheltenham.cs.arizona.edu; Sun, 20 Nov 1994 15:13:34 MST
To: icon-group-l@cs.arizona.edu
Date: 20 Nov 1994 21:40:31 GMT
From: ruiter@ruls41.fsw.LeidenUniv.nl (Jan-Peter de Ruiter)
Message-Id: <3aofof$f5m@highway.LeidenUniv.nl>
Organization: Leiden University, The Netherlands
Sender: icon-group-request@cs.arizona.edu
Subject: optional typing in Icon (longish)
Errors-To: icon-group-errors@cs.arizona.edu
Hi,
I've just finished reading (first pass) the book "The Implementation
of the Icon Programming Language" by Griswold & Griswold and I can
recommend any Icon programmer to read this book too. Not only is it
beautifully set, highly readable and very informative, it also gives
a whole new view on how powerful and sophisticated the language actually
is.
Having said this, I remember Tim Peters (who used to honor the
Icon newsgroup with helpful advice, and who did some outrageous
programming in Icon) saying in a private email to me that it
is a pity that the performance of Icon prevents the Icon
compiler/interpreter to be written in Icon.
This performance issue is one that I gladly take for granted seeing
how much time I save in developing Icon programs (as opposed to, say,
C programs) but I also agree with Tim that it would be nice to be
able to bootstrap Icon.
Being somewhat wiser after having read the book, I also fully understand
why the Icon compiler depends so heavily on run-time checks.
But I started analysing some of my Icon programs that I would like
to speed up, and noticed that many times *I* know (as opposed to the
compiler) that variable V is only used as {integer, string, real etc}
or as {list_of_integer, list_of_strings, table_of_strings_and_ints,
etc }. So my question is: what do you think of the option to add
*optional* type declarations to Icon? By optional type declarations
I mean something along these lines:
global count : table(string,integer,0)
procedure main()
local f : file
f := open("wordlist")
concordance(f)
end
procedure concordance(f : file)
local s : string
while s := read(f) do count[s] +:= 1
end
Please realise that the syntax does not matter here - the idea
is that if I know that s is only going to be used as string,
I can declare it to be a string-only variable. I don't *have* to,
but I can.
BTW, the typing scheme could of course allow for things like:
local count : table(list(string),list(real),[])
in other words, type embeddings could be allowed as well.
This optional typing would of course be truly optional. That is,
any Icon program without type declarations would run without
modification.
At the moment, I see great advantages in such an extension of
Icon. Allowing type declarations is not the same as enforcing
them, and nobody would be forced to use them. Programs could
be developped using dynamic-type variables as they are now, and
later be optimised by adding types.
I am aware of the fact that this would mean an extensive modification
of both the Icon compiler and interpreter. Also, I understand that
problems arise with mixing typed and untyped variables. In order to
allow for mixtures, a special type declaration (e.g. 'dynamic')
could be used to allow for mixing typed and dynamic variables.
Extending the Icon compiler would be a lot of work, I guess, but
the technology is already there - most compilers use type checking
and as you know probably better than me, the theory of typing
systems is quite advanced. For the runtime environment, I am
not sure excactly what the consequences would be.
The specific questions I have for the Icon community are:
o How much optimisation opportunities will arise from having
variables with a fixed type.
o How much speed & size performance gain could be expected from
this.
o Could a typed variable also lead to more efficient generators
and backtracking (over typed variables of course).
o Could a version of the Icon runtime environment be developed
that gives information on how often the type of all variables
changes during program execution (in order to obtain reliable
statistics on how often variables are, in effect, of fixed type)
o What do you generally think about this idea.
Any comments welcome. Please do not interpret this posting
as criticism on Icon, for it is not intended as such.
Greetings,
Jan